package entities;

import java.io.Serializable;

/**
 *@author Juan Alapin - 324507516
 *@author Giora Yaffe - 036551281
 *@author Shachar Gritzman - 300174026
 *@author Nir Porat - 021515580
*/
public class NotificationMessage implements Serializable{
	
	
	public static final String roles[] = {"supervisor" , "tester" , "execution leader" , "chairman" , "estimaor"};
	public static final int Ended=1;
	public static final int Terminated=2;
	public static final int Warning=3;
	public static final int Extension=4;
	public static final int Exception4PhaseManaer=5;
	public static final int Exception4Supervisor=6;
	public static final int Exception4DepManager=7;

	private static final long serialVersionUID = 1L;
	private int mID;
	private int usrID;
	private int processID;
	private int type;
	private String msg;
	private Boolean read;
	
	/**
	 * Constructor
	 * @param mID - Message's ID
	 * @param usrID - The user's ID the message attend for
	 * @param processID - the process the message came from
	 * @param type - type of the message
	 * @param read - is the recipient has read the the message
	 */
	public NotificationMessage(int mID, int usrID, int processID, int type, int read){
		this.mID = mID;
		this.usrID = usrID;
		this.processID = processID;
		setType(type);
		setMsg(type,usrID, processID);
		if (read==1)
			this.read = true;
		else 
			this.read = false;	
	}
	
	public int getmID() { return(mID); }
	
	public int getusrID() { return(usrID); }
	
	public int getprocessID() { return(processID); }
	
	public int gettype() { return(type); }
		
	public String getmsg() { return(msg); }
		

	public Boolean getread() { return(read); }
	
	/**
	 * Sets the read of a message to true or false
	 * @param b - is the recipient has read the the message
	 */
	public void setread(boolean b) {
		this.read = b;	
	}
	
	/**
	 * Sets the message's type
	 * @param type - type of the message
	 */
	public void setType(int type){
		if((type<8)&&(type>0)) this.type=type;
		else this.type=0;
	}
	
	/**
	 * Determine a text for the message
	 * @param type - type of the message
	 * @param userID - The user's ID the message attend for
	 * @param proID - the process the message came from
	 */
	public void setMsg(int type,int userID,int proID){
		switch(type){
					case NotificationMessage.Ended:
						this.msg = new String("Hello User "+userID+",Process Number: "+proID+" That You've Initiated Was Completed Successfully");
						break;
					case NotificationMessage.Terminated:
						this.msg = new String("Hello User "+userID+",Process Number: "+proID+" That You've Initiated Got Rejected");
						break;
					case NotificationMessage.Warning:
						this.msg = new String("Hello User "+userID+",The Deadline Of The Phase That You Manage In Process Number: "+proID+" Is Tomorrow, Keep Notice!");
						break;
					case NotificationMessage.Extension:
						this.msg = new String("Dear Department Manager, Process Number: "+proID+" Received A Time Extension");
						break;
					case NotificationMessage.Exception4PhaseManaer:
						this.msg = new String("Hello User  " + userID + " ,Phase Manager In Process Number: " + proID + ". The Process Has Exceeded The Assigned Time For You Phase");
						break;
					case NotificationMessage.Exception4Supervisor:
						this.msg = new String("Hello User " +userID+ ", Supervisor Of Process Number: "+proID+". The Process Has Exceeded The Assigned Time");
						break;
					case NotificationMessage.Exception4DepManager:
						this.msg = new String("Dear Department Manager, Process Number: "+proID+" Exceeded The Assigned Time");
						break;
						default:this.msg = new String("Unknown Message");
					}
	}
	
}
